import {get, post} from "@/api"
import {Scheme, SchemeQueryParam, SchemeStatus} from "@/ts/scheme";
import sysConfig from "@/config/index"

const baseURL="/client/scheme"

// 根据方案id获取方案
export function getSchemeById(id:number){
    return get(baseURL, "/detail", {
        id
    })
}
// 获取当前登录用户创建的方案分页
export function getSchemeListPageByUser(pageNum:number,param?:SchemeQueryParam){
    return get(baseURL,"/page/user",{
        current:pageNum,
        size:sysConfig.PAGE_SIZE,
        ...param
    })
}
// 获取分页方案
export function getSchemeListPage(pageNum:number,param?:SchemeQueryParam){
    return get(baseURL,"/page",{
        current:pageNum,
        size:sysConfig.PAGE_SIZE,
        ...param
    })
}
// 获取方案分页，且带有收藏数量和评分
export function getSchemeListPageForPublic(pageNum:number,param?:SchemeQueryParam){
    return get(baseURL,"/page/collectionNum",{
        current:pageNum,
        size:sysConfig.PAGE_SIZE,
        ...param
    })
}
// 获取用户收藏的方案分页
export function getSchemeListPageForCollection(pageNum:number,param?:SchemeQueryParam){
    return get(baseURL,"/page/collect",{
        current:pageNum,
        size:sysConfig.PAGE_SIZE,
        ...param
    })
}
export function addScheme(scheme:Scheme){

    scheme.schemeStatus = SchemeStatus.AUDITING
    return post(baseURL,"/add",scheme)
}
export function updateScheme(scheme:Scheme){
    return post(baseURL,"/edit",scheme)
}


export  function deleteScheme(id:string){
    return post(baseURL,"/delete",{
        id:id
    })
}


